package com.osdp.uc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.osdp.uc.entity.UcUserPosition;
import com.osdp.uc.mapper.UcUserPositionMapper;
import com.osdp.uc.service.IUcUserPositionService;
import com.osdp.uc.util.Fields;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UcUserPositionServiceImpl extends ServiceImpl<UcUserPositionMapper, UcUserPosition> implements IUcUserPositionService {

    @Override
    public boolean deleteUserPosition(String userId, String orgId){
        if(StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(orgId)) {
            return super.remove(new QueryWrapper<UcUserPosition>()
                    .eq(Fields.UcUserPositionQ.userId, userId)
                    .eq(Fields.UcUserPositionQ.orgId, orgId));
        }
        return false;
    }

    @Override
    public List<UcUserPosition> querUserPositionByUserOrgId(String userId, String orgId){
        if(StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(orgId)) {
            return super.list(new QueryWrapper<UcUserPosition>()
                    .eq(Fields.UcUserPositionQ.userId, userId)
                    .eq(Fields.UcUserPositionQ.orgId,orgId));
        }
        return Lists.newArrayList();
    }
}
